// import vuexstore from "@/store/index.js";

export default ({
  app,
}) => {
  app.router.beforeEach((to, from, next) => {
    if (to.path === '/profile') {
      // console.log(123, vuexstore().state.userInfo);
      if (localStorage.getItem('userinfo')) {
        next();
      } else {
        next(`/login?redirect=${to.path}`);
      }
    } else if (from.query && from.query.redirect) {
      next(from.query.redirect);
    } else {
      next();
    }
  });
};
